#!/bin/bash
#1 获取输入参数个数，如果没有参数，直接退出
FILE_COUNT=$#
if(($FILE_COUNT!=1)); then
    echo "错误：传递参数有误！"
    echo "用法：harbor.sh password"
    exit;
fi

# 开始下载
URL=https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.2-rc1.tgz
source ../linux/download_unzip.sh "harbor" $URL

# >>> source 调用本脚本时可用变量
# >>> $FILE_PATH 文件绝对路径：/opt/software/harbor-offline-installer-v1.8.2-rc1.tgz
# >>> $FILE_EXTENSI 文件后缀：tgz
# >>> $File_HOME 软件HOME：/opt/module/harbor/harbor
# >>> $REPO_PATH 仓库目录：/opt/repository/harbor

IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v 172.17.0.1|grep -v 10.0.2.15|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
ADMIN_PASSWORD=$1


# $ vim harbor.yml
sudo cat >$File_HOME/harbor.yml<<EOF
hostname: $IP #地址或域名
http:
	port: 80
https:
	port: 443
	certificate: harbor
	private_key: harbor
harbor_admin_password: $ADMIN_PASSWORD #  Web端admin用户密码
database:
	password: $ADMIN_PASSWORD
data_volumn: /data
EOF

# 执行
$File_HOME/install.sh
# 服务启动完成自动创建nginx和db等容器服务
# docker-compose ps
#==============================================
#                   使用前先登录
#==============================================
# $ docker login XXX.XXX.XXX.XXX
# Username: 
# Password: 
# Login Succeeded
# # 上传之前先打tag
# docker pull k8s.gcr.io/kubernetes-dashboard
# docker tag k8s.gcr.io/kubernetes-dashboard XXX.XXX.XXX.XXX/library/k8s.gcr.io/kubernetes-dashboard
# # 上传镜像
# docker push XXX.XXX.XXX.XXX/library/k8s.gcr.io/kubernetes-dashboard
# # 下载镜像
# docker pull XXX.XXX.XXX.XXX/library/k8s.gcr.io/kubernetes-dashboard
#==============================================
# 错误集 Requires: container-selinux >= 2.9
# yum install -y container-selinux
#==============================================





